home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: leeds.ac.uk!news
- From: men3sd@leeds.ac.uk (Stephen Davison)
- Subject: Desperate, and Dumb!!!
- Message-ID: <313E0301.15FB7483@leeds.ac.uk>
- NNTP-Posting-Host: englib4.leeds.ac.uk
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3C sun4m)
- Content-Type: text/plain; charset=us-ascii
- Organization: University of Leeds
- MIME-Version: 1.0
- Date: Wed, 6 Mar 1996 21:26:26 +0000 (GMT)
- CC: stephen@emissive.demon.co.uk
- Content-Transfer-Encoding: 7bit
-
- Hi,
-
- Only been C++'ing for about 2 months now and need a little help to get my project going so that I can finish
- it. I have copied a menu programme form a book, and have been trying to extend it so that is can call funcions
- that a) have parameters, b) return other than void.
-
- I have put some of the code bellow the error messages. It would be tops if some out there who knows what going
- on, could point me in the right direction. I really don't know what else to do!
-
- ********* Error's
- englib4% (337) !!
- make laycon
- Building start Executable
- Compiling and Linking Application
- CC -I/home/sunserv5_c/men3sd/step/classes -I/home/sunserv5_c/men3sd/step/men3sd -I/apps/steptools/include \
- -o laycon laycon.c \
- -L/home/sunserv5_c/men3sd/step/classes -L/home/sunserv5_c/men3sd/step/men3sd -L/apps/steptools/lib -lClasses
- -lrose \
- -lm
- "laycon.c", line 46: Error: Could not find a match for ActionItem<RoseDesign*>::ActionItem(char*, RoseDesign*).
- "laycon.c", line 47: Error: Could not find a match for ActionItem<void*>::ActionItem(char*, void()).
- 2 Error(s) detected.
- *** Error code 2
- make: Fatal error: Command failed for target `laycon'
- englib4% (338)
-
-
- laycon.c
- // laycon.c
-
- #include <rose.h>
- #include <sls_layered_manufacturing.h>
- #include "menu.h"
- #include "getFileName.h"
-
- void TestLine()
- {
- }
-
- void TestPoly()
- {
- }
-
- RoseDesign* OpenRoseFile(RoseDesign* designDataPtr)
- {
- FileName fileName;
- if (fileName.valid())
- {
- //designDataPtr = ROSE.useDesign(*fileName.fileName());
- }
- return(designDataPtr);
- }
-
- void OpenFile()
- {
- cout << "OPEN FILE NAME" << endl;
- fn.display();
- if (fn.valid())
- {
- cout << "Valid File Name" << fn.fileName();
- }
- }
-
- int main()
- {
- RoseDesign* designDataPtr;
- menu myMenu ( "MAIN MENU - LAYCON (c) 1996",
- new ActionItem<void*>("EXIT LAYCON" ),
- new ActionItem<RoseDesign*>("Open a design file", OpenRoseFile(designDataPtr)),
- new ActionItem<void*>("New", OpenFile),
- new SubMenuItem ("Manuipulate" ,
- new menu ("MANIPULATE MENU - LAYCON (c) 1996",
- new ActionItem<void*> ("back to MAIN MENU"),
- // new ActionItem ("Move", TestLine),
- // new ActionItem ("Rotate", TestPoly),
- // new ActionItem ("Scale", TestLine),
- MenuItem::END_ITEM ) ),
- // new SubMenuItem ("Sinterstation" ,
- // new menu ("SINTERSTATION MENU - LAYCON (c) 1996",
- // new ActionItem ("back to MAIN MENU"),
- // new ActionItem ("Generate Scan Vectors", TestLine),
- // new ActionItem ("Generate Sinterstation Data Files"),
- // MenuItem::END_ITEM ) ),
- // new ActionItem("Help", TestLine),
- // new ActionItem("Save the design file", TestLine),
- MenuItem::END_ITEM ) ;
-
- myMenu.activate() ;
- }
-
-
-
- ******* menu.h
-
-
- #ifndef menu_h
- #define menu_h
-
-
-
- //
- // Experimental menu system.
- //
-
- #include <iostream.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <string.h>
- #include <rose.h>
-
- typedef char * PtrChar ;
-
- class MenuItem
- {
- protected:
- PtrChar label ;
- MenuItem * next ;
- public:
- MenuItem(const PtrChar l = "", MenuItem *const n = 0)
- : label(strcpy(new char [strlen(l)+1], l)), next(n)
- { }
- virtual ~MenuItem()
- {
- delete label ; label = 0 ;
- delete next ; next = 0 ; }
- void connect(MenuItem *const item)
- {
- next = item ;
- }
-
- virtual MenuItem * deepCopy() const = 0 ;
- virtual BOOL activate(const int, const int) const = 0 ;
- virtual void print(const int count) const
- {
- cout << "\t" << count << ": " << label << endl ;
- if (next != 0)
- {
- next->print(count+1) ;
- }
- }
- enum { END_ITEM = 0 } ;
- } ;
-
- typedef MenuItem * PtrMenuItem ;
-
- class menu
- {
- protected:
- PtrChar label ;
- PtrMenuItem root ;
- public:
- menu(const PtrChar l, const PtrMenuItem r = 0)
- : label(strcpy(new char [strlen(l)+1], l) ), root(r)
- { }
-
- //
- menu(const PtrChar ...) ;
- menu(const menu & source)
- : root(0), label(0)
- {
- *this = source ;
- }
- ~menu()
- {
- delete label ; label = 0 ;
- delete root ; root = 0 ;
- }
- menu & operator = (const menu & source)
- {
- this->menu::~menu() ;
- if (source.label != 0)
- {
- label = strcpy(new char [strlen(source.label)+1], source.label) ;
- }
- if (source.root != 0)
- {
- root = source.root->deepCopy() ;
- }
- return *this ;
- }
- menu * deepCopy() const
- {
- return new menu (label, (root == 0) ? 0 : root->deepCopy() ) ;
- }
- void activate() const ;
- } ;
-
-
- typedef menu * PtrMenu ;
-
- //
- menu::menu(const PtrChar menuLabel ...)
- : label(strcpy(new char [strlen(menuLabel) + 1], menuLabel))
- {
- va_list parameterList ;
- va_start(parameterList, menuLabel) ;
- root = va_arg(parameterList, PtrMenuItem) ;
- PtrMenuItem endOfList = root ;
- while (1)
- {
- const PtrMenuItem nextitem = va_arg(parameterList, PtrMenuItem) ;
- if (nextitem == 0) break ;
- endOfList->connect(nextitem) ;
- endOfList = nextitem ;
- }
- va_end(parameterList) ;
- }
-
- //
- void menu::activate() const
- {
- int choice ;
- do
- {
- cout << endl << label << endl ;
- root->print(1) ;
- cout << endl << "Your selection: " ;
- cin >> choice ;
- }
- while (root->activate(choice, 1) ) ;
- }
-
- //
- static inline void unknownOption(int number)
- {
- cerr << endl << "Item " << number << " not a valid option." << endl ;
- }
-
- //
- class SubMenuItem : public MenuItem
- {
- protected:
- PtrMenu subMenu ;
- public:
- SubMenuItem(const PtrChar l, const PtrMenu m, SubMenuItem *const n = 0)
- : MenuItem(l, n), subMenu(m)
- { }
- ~SubMenuItem()
- {
- delete subMenu ;
- }
- PtrMenuItem deepCopy() const
- {
- return new SubMenuItem (label, subMenu->deepCopy(),
- (SubMenuItem *const)((next == 0) ? 0 : next->deepCopy())) ;
- }
- BOOL activate(const int, const int) const ;
- void print(const int count) const
- {
- cout << "\t" << count << ": " << label << " ==>" << endl ;
- if (next != 0)
- {
- next->print(count+1) ;
- }
- }
- } ;
-
- //
- BOOL SubMenuItem::activate(const int target, const int count) const
- {
- if (target == count)
- {
- if (subMenu != 0)
- {
- subMenu->activate() ;
- }
- else
- {
- cerr << "Empty menu activates." << endl ;
- }
- }
- else if ((target > count) && (next != 0))
- {
- return next->activate(target, count+1) ;
- }
- else
- {
- unknownOption(target) ;
- }
- return TRUE ;
- }
-
-
- //typedef void (*PtrVoidFunction)() ;
- //
- template <class any>
- class ActionItem : public MenuItem
- {
- protected:
- {
- return new menu (label, (root == 0) ? 0 : root->deepCopy() ) ;
- }
- void activate() const ;
- } ;
-
-
- typedef menu * PtrMenu ;
-
- //
- menu::menu(const PtrChar menuLabel ...)
- : label(strcpy(new char [strlen(menuLabel) + 1], menuLabel))
- {
- va_list parameterList ;
- va_start(parameterList, menuLabel) ;
- root = va_arg(parameterList, PtrMenuItem) ;
- PtrMenuItem endOfList = root ;
- while (1)
- {
- const PtrMenuItem nextitem = va_arg(parameterList, PtrMenuItem) ;
- if (nextitem == 0) break ;
- endOfList->connect(nextitem) ;
- endOfList = nextitem ;
- }
- va_end(parameterList) ;
- }
-
- //
- void menu::activate() const
- {
- int choice ;
- do
- {
- cout << endl << label << endl ;
- root->print(1) ;
- cout << endl << "Your selection: " ;
- cin >> choice ;
- }
- while (root->activate(choice, 1) ) ;
- }
-
- //
- static inline void unknownOption(int number)
- {static inline void unknownOption(int number)
- {
- cerr << endl << "Item " << number << " not a valid option." << endl ;
- }
-
- //
- class SubMenuItem : public MenuItem
- {
- protected:
- PtrMenu subMenu ;
- public:
- SubMenuItem(const PtrChar l, const PtrMenu m, SubMenuItem *const n = 0)
- : MenuItem(l, n), subMenu(m)
- { }
- ~SubMenuItem()
- {
- delete subMenu ;
- }
- PtrMenuItem deepCopy() const
- {
- return new SubMenuItem (label, subMenu->deepCopy(),
- (SubMenuItem *const)((next == 0) ? 0 : next->deepCopy())) ;
- }
- BOOL activate(const int, const int) const ;
- void print(const int count) const
- {
- cout << "\t" << count << ": " << label << " ==>" << endl ;
- if (next != 0)
- {
- next->print(count+1) ;
- }
- }
- } ;
-
- //
- BOOL SubMenuItem::activate(const int target, const int count) const
- {
- if (target == count)
- {
- if (subMenu != 0)
- {
- subMenu->activate() ;
- }
- else
- else
- {
- cerr << "Empty menu activates." << endl ;
- }
- }
- else if ((target > count) && (next != 0))
- {
- return next->activate(target, count+1) ;
- }
- else
- {
- unknownOption(target) ;
- }
- return TRUE ;
- }
-
-
- //typedef void (*PtrVoidFunction)() ;
- //
- template <class any>
- class ActionItem : public MenuItem
- {
- protected:
- typedef void (*PtrVoidFunction)(any);
- // any *() action;
-
- PtrVoidFunction action ;
-
- public:
- ActionItem<any>(const PtrChar l, /*PtrVoidFunction */ any * f,
- const PtrMenuItem n = 0)
- : MenuItem(l, n), action(*f)
- { }
- ActionItem<any>(const PtrChar l)
- : MenuItem(l), action(0)
- { }
- PtrMenuItem deepCopy() const
- {
- return new ActionItem<any>(label, action,
- (next == 0) ? 0 : next->deepCopy() ) ;
- }
- BOOL activate(const int, const int) const ;
- BOOL RETURN()
- { return FALSE ;
- }
-
- } ;
- template<class any>
-
- //
- BOOL ActionItem<any>::activate(const int target, const int count) const
- {
- const int RETURN = 0 ;
- if (target == count)
- {
- if (action == RETURN)
- {
- return FALSE ;
- }
- (*action)/*()*/ ;
- }
- else if ((target > count) && (next != 0))
- {
- return next->activate(target, count+1) ;
- }
- else
- {
- unknownOption(target) ;
- }
- return TRUE ;
- }
-
-
- #endif
-